//
//  CSSectionListStyleViewController.m
//  ChinaShip
//
//  Created by yyk on 2019/1/24.
//  Copyright © 2019年 ChinaShip. All rights reserved.
//

#import "CSSectionListStyleViewController.h"
#import "CSSectionDetailViewController.h"
#import "CSHomeSlideCollectionViewCell.h"
#import "CSSecondModel.h"
@interface CSSectionListStyleViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property (nonatomic,weak)IBOutlet UICollectionView *collectionView;
@end

@implementation CSSectionListStyleViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self showNavBar];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addBackNavbarItem];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"Capability Design";
    [self.collectionView registerNib:[UINib nibWithNibName:@"CSHomeSlideCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"CSHomeSlideCollectionViewCell"];
}


#pragma mark -UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.modelsList.count;
}

// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    CSHomeSlideCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CSHomeSlideCollectionViewCell" forIndexPath:indexPath];
    CSSecondModel *secondModel = self.modelsList[indexPath.row];
    [cell setSectionListStyleWithImgURL:ImageUrl(secondModel.cover) title:secondModel.name];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake((kSCREEN_WIDTH-60)/2, 257);
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(30, 20, 30, 20);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    CSSecondModel *secondModel = self.modelsList[indexPath.row];
    CSSectionDetailViewController *sectionDetailVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"CSSectionDetailViewController"];
    sectionDetailVC.mid = [secondModel.id integerValue];
    [self pushVcToOtherVc:sectionDetailVC];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
